home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Text⁄Files
/
Writeswell Jr. 1.0.2 Master
/
Writeswell Jr. Source
/
InitMenu.c
< prev
next >
Wrap
Text File
|
1992-10-23
|
4KB
|
168 lines
/* InitMenu.c
* ©1992 Working Software, Inc.
* This source code is copyrighted. Permission is granted to use the Word Services
* portion of the Writeswell Jr. source code in your own programs, but you
* may not distribute the Writeswell Jr. word-processor code as a
* commercial product. If you modify the code, please do not call it
* Writeswell Jr. (or Writeswell.) This will ensure that people understand the
* program and don’t have to deal with a number of different versions with
* who-knows-what going on in the code.
*
* Writeswell Jr. and Writeswell are trademarks of Working Software, Inc.
*/
#include <EPPC.h>
#include <AppleEvents.h>
#include "TBConstants.h"
#include "Prefs.h"
#include "InitMenu.h"
#include "Gripe.h"
#include "FontMenu.h"
#include "TBGlobals.h"
void SetServiceIcon( short item, short serviceNumber, MenuHandle servMenu );
void PutUpMenus( void )
{
Handle myMenuBar;
MenuHandle appleMenu;
MenuHandle fontMenu;
InitMenus();
myMenuBar = GetNewMBar( kMBarID );
if ( !myMenuBar ){
Gripe( "\pCannot get menu bar" );
return;
}
appleMenu = (MenuHandle)GetResource( 'MENU', kAppleMenuID );
if ( !appleMenu ){
Gripe( "\pcannot get Apple Menu Handle" );
return;
}
AddResMenu( appleMenu, 'DRVR' );
fontMenu = (MenuHandle)GetResource( 'MENU', kFontMenuID );
if ( !fontMenu ){
Gripe( "\pcannot get Font Menu Handle" );
return;
}
AddResMenu( fontMenu, 'FONT' );
InitStyleMenu();
SetMenuBar( myMenuBar );
DrawMenuBar();
return;
}
void PutUpSys6Menus( void )
{
MenuHandle servMenu;
PutUpMenus();
servMenu = GetServiceMenu();
if ( !servMenu ){
Gripe( "\pCannot get service menu handle" );
return;
}
DisableItem( servMenu, 0 ); /* Disable the whole menu */
DrawMenuBar();
return;
}
void PutUpSys7Menus( void )
{
PutUpMenus();
BuildServiceMenu();
}
OSErr BuildServiceMenu( void )
{
WWJrPrefsHdl prefHdl;
short i;
short servNum;
StringHandle menuStrHdl;
short curFile;
MenuHandle servMenu;
short resID;
prefHdl = GetPrefHandle();
if ( !prefHdl ){
Gripe( "\pCannot get preferences handle" );
return;
}
#ifdef NEVER /* This will return in a future version */
CheckSelectMenu( prefHdl );
#endif
servMenu = GetServiceMenu();
if ( !servMenu ){
Gripe( "\pCannot get service menu handle" );
return;
}
curFile = CurResFile();
UseResFile( gPrefFileRefNum );
/* This routine here could be modified to sort the service menu into some
* order, such as alphabetical, by associating the item numbers with the
* resource numbers in the desired order.
*/
servNum = 0;
for ( i = 0; i < kMaxServices; i++ ){
if ( (*prefHdl)->serviceType[ i ] != kNoService ){
resID = kServiceBaseID + i;
menuStrHdl = GetString( resID );
if ( !menuStrHdl ){
Gripe( "\pCannot get string resource for service menu" );
UseResFile( curFile );
return resNotFound;
}
HLock( menuStrHdl );
AppendMenu( servMenu, *menuStrHdl ); /* Note: this will interpret special chars */
HUnlock( menuStrHdl );
ReleaseResource( menuStrHdl );
SetServiceIcon( servNum + kSMDash + 1, i, servMenu );
gServItemID[ servNum++ ] = resID;
}
}
UseResFile( curFile );
return noErr;
}
void SetServiceIcon( short item, short serviceNumber, MenuHandle servMenu )
{
Handle sicnHandle;
short resID;
resID = kMenuIconBaseID + serviceNumber;
sicnHandle = GetResource( 'SICN', resID );
if ( !sicnHandle ){
return;
}
/* ReleaseResource( sicnHandle ); */
SetItemCmd( servMenu, item, (short) 0x01e );
SetItemIcon( servMenu, item, (unsigned char)(serviceNumber + 1) );
return;
}